const licenseWidth = 190
const getLicensesString = function(a) {
  let first = '执业类型未知'
  let all = []
  if (a && Array.isArray(a) && a.length > 0) {
    if (a.length === 1) {
      first = a[0].licenseTypeStr
      all = []
    } else {
      first = a[0].licenseTypeStr + '...'
      all = a.map(t => {
        return t.licenseTypeStr
      })
    }
  }
  return {
    first: first,
    all: all
  }
}


const salaryWidth = 150
const getSalaryItem = function(t) {
  return (t.tax === 0 ? '税前' : '税后') + (t.annualSalary ? t.annualSalary : '0') + 'W/' + (t.yearNum ? t.yearNum : '0') + '年'
}
const getSalaryString = function(a) {
  let first = '期望年薪未知'
  let all = []
  if (a && a.length > 0) {
    if (a.length === 1) {
      first = getSalaryItem(a[0])
      all = []
    } else {
      all = a.map(t => {
        return getSalaryItem(t)
      })
      first = all[0] + '...'
    }
  }
  return {
    first: first,
    all: all
  }
}

const getEllipsis = function(t, n) {
  if (t) {
    if (t.length > n) {
      return t.substr(0, n) + '...'
    } else {
      return t
    }
  } else {
    return ''
  }
}

export default {
  getEllipsis,
  licenseWidth,
  getLicensesString,
  salaryWidth,
  getSalaryString,
}